<template>
  <div class="graph-analyze">
    <div
      v-if="knowledgeTree"
      ref="knowledgeDrawer"
      class="knowledge-drawer"
      :style="{
        transform: open ? 'translate(0vw,-50%)' : 'translate(-18vw,-50%)',
        transition: 'all 0.3s ease',
        boxShadow: open ? '' : '0 0 10px 0 rgba(0, 0, 0, 0.1)'
      }"
    >
      <div class="title">
        <span>知识点列表</span
        ><span class="data-tip">{{
          activeTab === 'right-rate' ? '正确率' : '掌握度'
        }}</span>
      </div>
      <el-scrollbar height="90%">
        <a-tree
          :tree-data="[knowledgeTree]"
          :fieldNames="{
            key: 'id',
            title: 'title',
            children: 'children'
          }"
          blockNode
          @expand="onExpand"
          @select="onSelect"
          :expandedKeys
          style="padding-right: 1vw"
        >
          <template #title="tree">
            <div class="point-title">
              <span>{{ tree.name }}</span>
              <span
                v-if="getCurCount(tree)"
                class="correct"
                :style="{ color: getColorByRate(getCurRate(tree)) }"
                >{{ (getCurRate(tree) * 100).toFixed(2) + '%' }}</span
              >
              <span v-if="!getCurCount(tree)" style="color: #ccc">--</span>
            </div>
          </template>
        </a-tree>
      </el-scrollbar>
      <div class="show-btn" @click="switchDrawer">
        知识点列表
        <img src="@/assets/images/target-boost/icon-switch.svg?url" />
      </div>
      <div class="show-list" v-if="open" @click="isShowList = true">
        <img src="@/assets/images/target-boost/enlarge.svg?url" />
      </div>
    </div>
    <div class="graph-container">
      <div class="graph" ref="chart"></div>
      <div class="show-switch" @click="onSwitchD3Graph" title="点击切换图谱">
        <span>旧视图</span>
        <img src="@/assets/images/target-boost/icon-switch-graph.svg?url" />
      </div>
      <div class="parent-node" v-if="allParentNode.length">
        <el-breadcrumb separator="">
          <transition-group name="list" appear mode="in-out">
            <el-breadcrumb-item
              v-for="(node, index) in allParentNode"
              :key="node.id"
              @click="clickBreadcrumb(node)"
              class="breadcrumb-item"
            >
              <span class="breadcrumb-text">{{ node.name }}</span>
              <!-- 最后一个节点不显示分隔符 -->
              <span v-if="index !== allParentNode.length - 1" class="separator"
                >/</span
              >
            </el-breadcrumb-item>
          </transition-group>
        </el-breadcrumb>
      </div>
    </div>

    <template v-if="activeTab === 'right-rate'">
      <el-scrollbar height="90vh" class="aside" v-if="isShowDetail">
        <DetailLeft
          v-model:sidebarData="sidebarData"
          @close="isShowDetail = false"
          @toDetail="emit('toDetail', null, $event)"
          showClose
          showDetail
          :selectTime
          :currentGradeNum
          :subjectId
          :classId
          :isCompare
        />
      </el-scrollbar>
      <Sidebar
        class="aside"
        v-else
        v-model:isCompare="isCompare"
        v-model:currentTabIndex="currentTabIndex"
        v-model:sidebarData="sidebarData"
        :knowledgeTree="detailData"
        :count="curCount(knowledgeTree)"
        :listWeaknesses
        :strengthsAndWeaknesses
        :masteredKnowledgePoints
        :unmasteredKnowledgePoints
        :knowledgeId
        :getAllParentNodes
        :compareLabel
        :selectTime
        :currentGradeNum
        :subjectId
        :classId
        @changeDetail="changeDetail"
        @changeGraph="changeGraph"
        @toDetail="toDetail"
        @showDetail="isShowDetail = true"
      />
      <Teleport to="body">
        <transition name="list" mode="out-in">
          <div v-show="isShowModal" class="modal" ref="modal" @click="dropped">
            点击下探知识点
          </div>
        </transition>
      </Teleport>
    </template>
    <template v-else>
      <el-scrollbar height="90vh" class="aside">
        <mastery-point-detail
          v-if="isShowDetail"
          :selectTime="selectTime"
          v-model:sidebarData="sidebarData"
          :knowledgeId="knowledgeId"
          :showClose="true"
          :classId="classId"
          :currentGradeNum="currentGradeNum"
          :subjectId="subjectId"
          @close="isShowDetail = false"
          @toDetail="emit('toDetail', null, $event)"
        ></mastery-point-detail>
        <mastery-level-sidebar
          :selectTime="selectTime"
          v-model:sidebarData="sidebarData"
          :isShowDetail="isShowDetail"
          :knowledgeId="knowledgeId"
          :classId="classId"
          :currentGradeNum="currentGradeNum"
          :listWeaknesses="listWeaknesses"
          :masteredKnowledgePoints="masteredKnowledgePoints"
          :unmasteredKnowledgePoints="unmasteredKnowledgePoints"
          @toDetail="toDetail"
          @showDetail="isShowDetail = true"
          v-else
        />
      </el-scrollbar>
    </template>
  </div>
</template>
<script setup>
import {
  ref,
  reactive,
  watch,
  onMounted,
  onUnmounted,
  nextTick,
  defineModel,
  computed,
  shallowRef,
  toRaw,
  inject
} from 'vue'

import { useRoute } from 'vue-router'

import DetailLeft from './DetailLeft.vue'
import Sidebar from './Sidebar.vue'
import MasteryPointDetail from './MasteryPointDetail.vue'
import MasteryLevelSidebar from './MasteryLevelSidebar.vue'

import { useEcharts } from '@/hooks'
import { getColorByRate, findNodeById } from '../../utils'
import { useKnowledgeStore } from '@/stores'
const route = useRoute()

const emit = defineEmits(['toDetail'])

const onSwitchD3Graph = inject('onSwitchD3Graph')

const props = defineProps({
  activeTab: String,
  selectObj: Object,
  knowledgeTree: Object,
  currentGradeNum: Number,
  subjectId: Number,
  classId: String,
  selectTime: Array,
  isLoading: Boolean,
  nodeLookup: Object,
  compareLabel: String
})

const knowledgeDrawer = ref(null)
const open = ref(false)
const switchDrawer = () => {
  open.value = !open.value
}
const handleClickOutside = event => {
  console.log(knowledgeDrawer.value)
  if (!knowledgeDrawer.value) {
    return
  }
  if (!knowledgeDrawer.value?.contains(event.target)) {
    open.value = false
  }
}

onMounted(() => {
  document.addEventListener('click', handleClickOutside)
})

onUnmounted(() => {
  document.removeEventListener('click', handleClickOutside)
})

const getCurCount = data => {
  if (props.activeTab === 'right-rate') {
    if (route.query.studentId) {
      return data.personal_count
    }
    return data.class_count
  } else {
    if (route.query.studentId) {
      return data.mastery_rate?.personal_count
    }
    return data.mastery_rate?.class_count
  }
}

const getCurRate = data => {
  if (props.activeTab === 'right-rate') {
    if (route.query.studentId) {
      return data.personal_rate
    }
    return data.class_rate
  } else {
    if (route.query.studentId) {
      return data.mastery_rate?.personal_rate
    }
    return data.mastery_rate?.class_rate
  }
}

const curCount = node => {
  return route.query.studentId ? node?.personal_count : node?.class_count
}

const chart = ref(null)
const option = reactive({
  tooltip: {
    trigger: 'item',
    triggerOn: 'mousemove',
    formatter: e => {
      const t = e.color
      if (route.query.studentId) {
        return `<div>${e.name}</div>\n        <div style="color: ${t}">${
          props.activeTab === 'right-rate' ? '正确率：' : '掌握度'
        }${(
          (props.activeTab === 'right-rate'
            ? e.data.personal_rate
            : e.data?.mastery_rate?.personal_rate) * 100
        ).toFixed(2)}%  ${
          props.activeTab === 'right-rate'
            ? '习题量：' + e.data.personal_count
            : ''
        }</div>\n  ${
          isCompare.value
            ? `<div>对比 ${props.compareLabel}</div>\n <div >${
                props.activeTab === 'right-rate' ? '正确率：' : '掌握度'
              }：${(
                (props.activeTab === 'right-rate'
                  ? e.data.grade_rate
                  : e.data?.mastery_rate.grade_rate) * 100
              ).toFixed(2)}%  ${
                props.activeTab === 'right-rate'
                  ? '习题量：' + e.data.grade_count
                  : ''
              }</div>\n`
            : ''
        }       <div style="color: #999; font-size: 14px; margin-top: 10px;">点击“知识点”查看详情</div>\n        `
      }

      return `<div>${e.name}</div>\n        <div style="color: ${t}">${
        props.activeTab === 'right-rate' ? '正确率：' : '掌握度'
      }：${(
        (props.activeTab === 'right-rate'
          ? e.data.class_rate
          : e.data?.mastery_rate?.class_rate) * 100
      ).toFixed(2)}% ${
        props.activeTab === 'right-rate' ? '习题量：' + e.data.class_count : ''
      }</div>\n ${
        isCompare.value
          ? `<div>对比 ${props.compareLabel}</div>\n <div >${
              props.activeTab === 'right-rate' ? '正确率：' : '掌握度'
            }：${(
              (props.activeTab === 'right-rate'
                ? e.data.grade_rate
                : e.data?.mastery_rate?.grade_rate) * 100
            ).toFixed(2)}%  ${
              props.activeTab === 'right-rate'
                ? '习题量：' + e.data.grade_count
                : ''
            }</div>\n`
          : ''
      }        <div style="color: #999; font-size: 14px; margin-top: 10px;">点击“知识点”查看详情</div>\n        `
    }
  },

  series: [
    {
      type: 'tree',
      data: [],
      roam: true,
      layout: 'radial',
      symbol: 'circle',
      top: '1%',
      left: '1%',
      bottom: '1%',
      right: '1%',
      label: {
        show: false
      },
      expandAndCollapse: false,
      animationDurationUpdate: 750,
      initialTreeDepth: -1,
      emphasis: {
        focus: 'descendant',
        itemStyle: {
          borderColor: '#fff',
          borderWidth: 1,
          opacity: 1
        }
      },
      lineStyle: {
        width: 1
      }
    }
  ]
})
function getItemStyle(rate, count, node) {
  const base = {
    borderColor: '#fff',
    borderWidth: 1,
    opacity: 3
  }

  if (isCompare.value && props.activeTab === 'right-rate') {
    if (node.grade_rate === rate && count) {
      return {
        color: '#D92325' || '#D46262',
        ...base
      }
    }
    if (node.grade_count > 0 && rate === 0 && count) {
      return {
        color: '#D92325' || '#D46262',
        ...base
      }
    }
    if (node.grade_rate === 0 && !rate && count) {
      return {
        color: '#D92325' || '#D46262',
        ...base
      }
    }
    if (count === 0) {
      return {
        color: '#CCCCCC' || '#E0E0E0',
        ...base
      }
    }

    if (node.grade_rate > rate) {
      return {
        color: '#D92325' || '#D46262',
        ...base
      }
    } else {
      return {
        color: '#18783B' || '#6FA976',
        ...base
      }
    }
  }
  if (rate >= 0.95) {
    return {
      color: '#19783B' || '#6FA976',
      ...base
    }
  } else if (rate >= 0.85) {
    return {
      color: '#32B16C' || '#4EC680',
      ...base
    }
  } else if (rate >= 0.8) {
    return {
      color: '#B3D465' || '#71D764',
      ...base
    }
  } else if (rate >= 0.6) {
    return {
      color: '#EC6941' || '#FF6D65',
      ...base
    }
  } else if (rate > 0 || (rate === 0 && count !== 0)) {
    return {
      color: '#D92325' || '#D46262',
      ...base
    }
  } else {
    return {
      color: '#CCCCCC' || '#E0E0E0',
      ...base
    }
  }
}
function getSymbolSize(value, depth, node) {
  if (
    (isCompare.value && value === 0 && node.grade_count === 0) ||
    (!isCompare.value && value === 0)
  ) {
    return 8
  }

  // 根据层级返回不同的大小
  switch (depth) {
    case 1:
      return 25
    case 2:
      return 20
    case 3:
      return 15
    default:
      return 12
  }
}

// 薄弱知识点列表
const listWeaknesses = ref([])
// 优劣势列表
const strengthsAndWeaknesses = ref({
  strengthList: [],
  weaknessList: []
})
// 已掌握知识点列表
const masteredKnowledgePoints = ref([])
// 待掌握知识点列表
const unmasteredKnowledgePoints = ref([])

// 知识点体系选中的知识点id, 这个是sidebar的靶向概览需要用到
const knowledgeId = computed(() => {
  return detailData.value?.id || 0
})
const isCompare = defineModel('isCompare')
const currentTabIndex = defineModel('currentTabIndex')
const isShowList = defineModel('isShowList')
const isComputed = ref(false)

// 给知识点树添加颜色样式以及添加弱项知识点,这个函数会被执行很多次，到时候想办法优化
function applyItemStyle(data, depth = 1) {
  const processNode = (node, depth) => {
    let nodeRate, nodeCount
    // 掌握度
    if (props.activeTab === 'mastery-level') {
      if (route.query.studentId) {
        nodeRate = node.mastery_rate?.personal_rate || 0
        nodeCount = node.mastery_rate?.personal_count || 0
      } else {
        nodeRate = node.mastery_rate?.class_rate || 0
        nodeCount = node.mastery_rate?.class_count || 0
      }
    } else {
      // 学生页面就使用personal_rate和personal_count，班级页面就使用class_rate和class_count
      if (route.query.studentId) {
        nodeRate = node.personal_rate
        nodeCount = node.personal_count
      } else {
        nodeRate = node.class_rate
        nodeCount = node.class_count
      }
    }

    node.symbolSize = getSymbolSize(nodeCount, depth, node)
    node.itemStyle = getItemStyle(nodeRate, nodeCount, node)

    // 如果已经计算过了就不需要再计算了
    if (!isComputed.value) {
      // 掌握度数据
      if (props.activeTab === 'mastery-level') {
        // 薄弱点计算
        if (nodeRate < 0.75 && nodeCount > 0) {
          listWeaknesses.value.push(node)
        }
        // 已掌握知识点
        if (nodeRate >= 0.95) {
          masteredKnowledgePoints.value.push(node)
        }
        // 中等知识点
        if (nodeRate >= 0.75 && nodeRate < 0.95) {
          unmasteredKnowledgePoints.value.push(node)
        }
      } else {
        // 薄弱点计算
        if (nodeRate < 0.6 && nodeCount > 0) {
          listWeaknesses.value.push(node)
        }
        // 已掌握知识点
        if (nodeRate >= 0.8) {
          masteredKnowledgePoints.value.push(node)
        }
        // 待掌握知识点
        if (nodeRate >= 0.6 && nodeRate < 0.8) {
          unmasteredKnowledgePoints.value.push(node)
        }
      }
      // 优劣势计算
      const compareRate = nodeRate - node.grade_rate
      node.compare_rate = compareRate
      if (compareRate > 0 && node.class_count && node.grade_count) {
        strengthsAndWeaknesses.value.strengthList.push(node)
      } else if (nodeRate !== 0 && compareRate > 0 && nodeCount) {
        strengthsAndWeaknesses.value.strengthList.push(node)
      } else if (nodeRate === 0 && compareRate === 0 && nodeCount) {
        strengthsAndWeaknesses.value.weaknessList.push(node)
      } else if (compareRate < 0) {
        strengthsAndWeaknesses.value.weaknessList.push(node)
      }
    }

    if (node.children) {
      applyItemStyle(node.children, depth + 1)
    }
  }

  if (Array.isArray(data)) {
    data.forEach(node => processNode(node, depth))
  } else {
    processNode(data, depth)
  }
}

const isShowDetail = ref(false)
// 这个文件中使用了JSON去深拷贝是为了解除响应式，修改这个响应式的数据会导致性能卡顿
const detailData = shallowRef(props.knowledgeTree)

const sidebarData = ref(JSON.parse(JSON.stringify(props.knowledgeTree)))
const changeDetail = detail => {
  sidebarData.value = JSON.parse(JSON.stringify(detail))
  isShowDetail.value = true
}

// 根据isClassRate是使用的参数来决定是使用class_rate还是grade_rate
const changeGraph = async iscompare => {
  if (iscompare === isCompare.value) {
    return
  }

  isCompare.value = iscompare
  await nextTick()
  const newData = JSON.parse(JSON.stringify(detailData.value))
  applyItemStyle(newData)
  option.series[0].data = [newData]
}

const toDetail = (_, e) => {
  emit('toDetail', null, e)
}

const { addEvent, showLoading, hideLoading } = useEcharts(chart, option)

const changeChart = () => {
  // 重置薄弱点
  listWeaknesses.value = []

  isComputed.value = false
  masteredKnowledgePoints.value = []
  unmasteredKnowledgePoints.value = []
  strengthsAndWeaknesses.value.strengthList = []
  strengthsAndWeaknesses.value.weaknessList = []
  // 给知识点树添加颜色样式以及添加弱项知识点
  applyItemStyle(detailData.value)
  console.log(strengthsAndWeaknesses.value.weaknessList)
  isComputed.value = true
  // 这个listWeaknesses在applyItemStyle改变了数据，所以需要重新排序
  console.log(listWeaknesses.value)
  if (route.query.studentId) {
    listWeaknesses.value = listWeaknesses.value.sort(
      (a, b) => a.personal_rate - b.personal_rate
    )
  } else {
    listWeaknesses.value = listWeaknesses.value.sort(
      (a, b) => a.class_rate - b.class_rate
    )
  }

  // 优劣势计算, 并截取前15个
  strengthsAndWeaknesses.value.strengthList =
    strengthsAndWeaknesses.value.strengthList
      .sort((a, b) => a.compare_rate - b.compare_rate)
      .slice(0, 15)
  strengthsAndWeaknesses.value.weaknessList =
    strengthsAndWeaknesses.value.weaknessList
      .sort((a, b) => a.compare_rate - b.compare_rate)
      .slice(0, 15)

  option.series[0].data = [detailData.value]
}

// 监听 isLoading 的变化
watch(
  () => props.isLoading,
  isLoading => {
    if (isLoading) {
      showLoading()
    } else {
      hideLoading()
    }
  }
)

// 获取所有父节点
const getAllParentNodes = nodeId => {
  const parents = []
  let currentNode = props.nodeLookup[nodeId]
  while (currentNode && currentNode.parentId !== null) {
    currentNode = props.nodeLookup[currentNode.parentId]
    if (currentNode) {
      parents.push(currentNode)
    }
  }

  return parents.reverse()
}

let currentNode = JSON.parse(JSON.stringify(props.knowledgeTree))
console.log(currentNode)

const knowledgeStore = useKnowledgeStore()
addEvent('click', function (params) {
  // if (currentNode && currentNode.id === params.data.id) {
  // if (allParentNode.value.length > 0) {
  //   const parentNode = allParentNode.value.pop()
  //   detailData.value = JSON.parse(JSON.stringify(parentNode))
  //   currentNode = parentNode

  // } else {
  //   detailData.value = JSON.parse(JSON.stringify(props.knowledgeTree))
  //   currentNode = detailData.value

  // }

  //   changeChart()
  //   return
  // }
  // 当选中知识点的时候，清空选中的学生
  if (knowledgeStore.selectedStudent.length) {
    knowledgeStore.setSelectedStudent([])
  }
  // 选中知识点
  currentNode = JSON.parse(JSON.stringify(params.data))
  sidebarData.value = JSON.parse(JSON.stringify(params.data))
  isShowDetail.value = true
})

// 右键菜单
const isShowModal = ref(false)
const modal = ref(null)
const allParentNode = ref([])

const clickBreadcrumb = node => {
  // 查找到点击的节点，删除点击的当前节点后的所有节点
  allParentNode.value.findIndex((item, i) => {
    if (item.id === node.id) {
      detailData.value = JSON.parse(JSON.stringify(item))
      changeChart()
      // knowledgeStore.setKnowledgeTree(item)
      console.log(allParentNode.value)
      allParentNode.value.splice(i)
      console.log(allParentNode.value)

      return true
    }
  })
}

const baseURL = import.meta.env.DEV ? '' : '/ai-learn-pc'
const worker = new Worker(`${baseURL}/workers/get-all-parent-nodes.js`)

// 知识点抽屉
const expandedKeys = ref([])

const onExpand = value => {
  expandedKeys.value = value
}

const changeKnowledgeTree = node => {
  strengthsAndWeaknesses.value.strengthList = []
  strengthsAndWeaknesses.value.weaknessList = []
  detailData.value = JSON.parse(JSON.stringify(node))
  knowledgeStore.setKnowledgeTree(node)
  changeChart()
}

const onSelect = (checkedKeys, { node }) => {
  changeKnowledgeTree(node.dataRef)

  worker.postMessage({
    action: 'getAllParentNodes',
    nodeId: node.id,
    nodeLookup: toRaw(props.nodeLookup)
  })
}

const rootId = ref(-1)

// 监听 knowledgeTree 的变化
watch(
  () => [props.knowledgeTree, props.activeTab],
  async () => {
    const newTree = props.knowledgeTree
    rootId.value = newTree.id
    expandedKeys.value = [rootId.value]

    // 如果传入的是加载状态，直接显示 loading
    if (props.isLoading) {
      showLoading()
      return
    }

    await nextTick()

    if (newTree.id === rootId.value) {
      if (detailData.value && newTree.id === detailData.value.id) {
        detailData.value = JSON.parse(
          JSON.stringify(props.nodeLookup[detailData.value.id])
        )
      } else {
        let currentNode =
          rootId.value !== props.knowledgeTree.id
            ? findNodeById(newTree, detailData.value.id)
            : JSON.parse(JSON.stringify(newTree))
        detailData.value = currentNode
      }
      changeChart()
    }

    hideLoading()
  },
  { immediate: true }
)

const dropped = () => {
  changeKnowledgeTree(selectedNode)
  // 获取所有父节点，侧边栏的面包屑需要
  isShowModal.value = false
  console.log(worker)
  worker.postMessage({
    action: 'getAllParentNodes',
    nodeId: selectedNode.id,
    nodeLookup: toRaw(props.nodeLookup)
  })
}
worker.onmessage = function (e) {
  const { action, parents } = e.data
  if (action === 'getAllParentNodes') {
    console.log(parents)

    allParentNode.value = parents
  }
}

onUnmounted(() => {
  worker.terminate()
})

// 右键选择的节点
let selectedNode = null
addEvent('contextmenu', async function (params) {
  // 阻止右键默认事件
  params.event.stop()
  // 如果点击的是同一个节点，则不显示弹窗
  if (selectedNode && selectedNode.id === params.data.id) {
    isShowModal.value = false
    selectedNode = null
    return
  }
  const showOperate = () => {
    isShowModal.value = true
    selectedNode = JSON.parse(JSON.stringify(params.data))
    // 浏览器的放大倍数
    const scale = document.documentElement.clientWidth / 1920
    // 弹窗在点击的位置出现
    modal.value.style.left = params.event.event.clientX - 120 * scale + 'px'
    modal.value.style.top = params.event.event.clientY + 'px'
  }
  if (isShowModal.value) {
    isShowModal.value = false
    setTimeout(() => {
      showOperate()
    }, 200)
    return
  }
  showOperate()
})
const hideModal = event => {
  if (isShowModal.value && modal.value && !modal.value.contains(event.target)) {
    isShowModal.value = false
    selectedNode = null
  }
}

onMounted(() => {
  document.addEventListener('click', hideModal)
})

onUnmounted(() => {
  document.removeEventListener('click', hideModal)
})
// 这个监听很重要监听了detailData.value的变化，当detailData.value变化的时候，会重新计算symbolSize和itemStyle
// 暂时先去除，这个是拿到节点的父节点
// watch(
//   () => detailData.value,
//   val => {
//     if (val) {
//       const newData = JSON.parse(JSON.stringify(val))
//       console.log(1)

//       applyItemStyle(newData)
//       console.log(chartInstance.value)
//       option.series[0].data = [newData]
//       chartInstance.value.clear()
//       // 获取所有父节点，侧边栏的面包屑需要
//       allParentNode.value = getAllParentNodes(newData.id)
//     }
//   }
// )
</script>
<!-- eslint-disable -->
<style lang="less">
.modal {
  position: absolute;
  top: 0;
  left: 0;
  background-color: #fff;
  font-size: 12px;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  color: #333;
  cursor: pointer;
  &:hover {
    color: @color-brand-regular;
  }
}
</style>

<style lang="less" scoped>
.graph-analyze {
  position: relative;
  display: flex;
  height: 100%;
  overflow: hidden;
  border-radius: 10px;

  .knowledge-drawer {
    position: absolute;
    top: calc(50% + 30px);
    height: 85%;
    width: 18vw;
    padding: 0 0 20px 20px;
    background-color: #fff;
    box-shadow: 3px 0 10px #ccc;
    z-index: 1;

    :deep(.ant-tree-treenode) {
      width: 100%;
      .ant-tree-node-content-wrapper {
        display: inline-block;
        width: 100%;
      }
      .ant-tree-node-selected {
        background-color: #367cff69;
      }
    }

    .title {
      font-size: 18px;
      font-weight: 500;
      margin-top: 30px;
      margin-bottom: 25px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-right: 1vw;

      .data-tip {
        font-size: 16px;
      }
    }
    .point-title {
      width: 100%;
      display: flex;
      justify-content: space-between;
      .correct {
        margin-left: px;
      }
    }

    .show-btn {
      position: absolute;
      top: 20%;
      transform: translateY(-50%);
      right: -61px;
      width: 61px;
      padding: 23px;
      text-align: center;
      background-color: #e5f5ff;
      color: #040b1ad9;
      cursor: pointer;
      border-radius: 0 10px 10px 0;

      img {
        width: 15px;
      }
    }

    .show-list {
      position: absolute;
      top: 40%;
      transform: translateY(-50%);
      right: -61px;
      width: 61px;
      padding: 20.5px;
      text-align: center;
      background-color: #e5f5ff;
      color: #040b1ad9;
      cursor: pointer;
      border-radius: 0 10px 10px 0;
    }
  }

  .graph-container {
    position: relative;
    flex: 1;
    box-sizing: border-box;
    height: 90vh;
    background-color: #fff;
    border-radius: 10px;
    .graph {
      width: 100%;
      height: 100%;
    }

    .show-switch {
      position: absolute;
      left: 43px;
      bottom: 20px;
      padding: 20.5px;
      text-align: center;
      color: #040b1ad9;
      cursor: pointer;
      font-size: 20px;
      img {
        width: 25px;
        margin-left: 10px;
      }
    }

    .parent-node {
      display: flex;
      align-items: center;
      position: absolute;
      top: 0;
      left: 50%;
      font-size: 16px;
      height: 60px;
      transform: translateX(-50%);
      z-index: 9999;
      transition: all 0.3s ease;
      .breadcrumb-item {
        display: inline-block;
        white-space: nowrap;
        transition: all 0.3s ease;
        cursor: pointer;
        .breadcrumb-text {
          display: inline-block;
          padding: 0 5px;
          cursor: pointer;
          &:hover {
            color: @color-brand-regular;
          }
        }
        :deep(.el-breadcrumb__separator) {
          display: none;
        }
      }
    }
  }

  .aside {
    margin-left: 20px;
    width: 388px;
    height: 90vh;
    border-radius: 10px;
  }

  :deep(.left-container) {
    padding-top: 0;
  }
}
</style>
